#!/bin/bash

echo "Starting deployment with Python 3.7..."

# 设置Python路径
PYTHON_PATH="/usr/local/bin/python3.7"

# 创建虚拟环境
echo "Creating virtual environment..."
$PYTHON_PATH -m venv venv

# 激活虚拟环境
echo "Activating virtual environment..."
source venv/bin/activate

# 升级pip
echo "Upgrading pip..."
python -m pip install --upgrade pip

# 安装依赖
echo "Installing dependencies..."
python -m pip install -r requirements.txt

# 数据库迁移
echo "Running database migrations..."
python manage.py migrate

# 收集静态文件
echo "Collecting static files..."
python manage.py collectstatic --noinput

# 运行检查
echo "Running Django checks..."
python manage.py check

echo "Deployment completed successfully!"